#include <iostream>
using namespace std;

// 计一个Bank类，实现银行某账号的资金往来账目管理，包括建账号、存入、取出等。

class Bank
{
public:
    Bank(string date, int money, int rest, int sum)
    {
        this->date = date;
        this->money = money;
        this->rest = rest;
        this->sum = sum;
    }

    // 存入
    void backin(int money)
    {
        cout << "存入：" << money << endl;
        this->money = money;
        rest += money;
        sum += rest;
    }

    // 取出
    void backout(int money)
    {
        if (money > rest)
        {
            cout << "余额不足" << endl;
            return;
        }
        cout << "取出：" << money << endl;
        this->money = money;
        rest -= money;
        sum -= rest;
    }
    void display()
    {
        cout << "上一次交易：" << "日期：" << date;

        if (money > 0)
        {
            cout << " 存入：" << money;
        }
        else if (money == 0)
        {
            cout << " 无交易";
        }
        else
        {
            cout << " 取出：" << money;
        }
        cout << " 余额：" << rest << " 累计余额：" << sum << endl;
    }

private:
    string date;
    int money; // 金额
    int rest;  // 余额
    int sum;   // 累计余额
};

int main()
{
    Bank b1("2022-10-13", 0, 1000, 1000);
    b1.display();
    b1.backin(1000);
    b1.display();
    b1.backout(1000);
    b1.display();
    return 0;
}